Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class com.pacist.diamonds.FlexiButton

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--com.pacist.diamonds.DiamondCanvas
                    |
                    +--com.pacist.diamonds.DrawnButton
                          |
                          +--com.pacist.diamonds.FlexiButton

public class FlexiButton
extends DrawnButton
implements Direction
A button whose label consists of colored text and/or an image.

See Also:
Serialized Form

Field Summary
boolean canMeasure
          Determines whether the button may use the dimensions of the image and label or not.
java.awt.Image downDisabledImage
          The image displayed when the button is being held down, but disabled.
java.awt.Image downImage
          The image displayed when the button is being held down.
boolean draw3DLabel
          Determines whether a 3D label should be drawn or not.
int height
          Height of FlexiButton.
int hMargin
          Horizontal margin.
int imagePos
          Position of image relative to the label.
java.lang.String label
          The text label for the button.
boolean showImage
          Determines whether the image should be shown or not.
boolean showLabel
          Determines whether the label should be shown or not.
int spacing
          Space between the image and the label.
java.awt.Image upDisabledImage
          The image displayed when the button is untouched, but disabled.
java.awt.Image upImage
          The image displayed when the button is untouched.
int vMargin
          Vertical margin.
int width
          Width of FlexiButton.
 
Fields inherited from class com.pacist.diamonds.DrawnButton
armed, behaviour, BUTTON, buttonListeners, flags, LABEL, mouseIn, NOTIFY_ARM, NOTIFY_DISARM, RADIO, SHADOW_ALL, SHADOW_BORDER, SHADOW_BOTTOM, SHADOW_LEFT, SHADOW_NONE, SHADOW_RIGHT, SHADOW_ROUNDED, SHADOW_TOP, shadowType, state, states, TOGGLE, tracking, TRISTATE, what
 
Fields inherited from class com.pacist.diamonds.DiamondCanvas
tipText
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
FlexiButton()
          Creates and initializes a FlexiButton object, with the behaviour of a button.
FlexiButton(java.awt.Image label)
          Creates and initializes a FlexiButton object, with the behaviour of a button, and using the specified image.
FlexiButton(java.lang.String label)
          Creates and initializes a FlexiButton object, with the behaviour of a button, and using the specified label.
FlexiButton(java.lang.String label, java.awt.Image upImage, int behaviour)
          Creates and initializes a FlexiButton object, with the specified behaviour, label, and image.
FlexiButton(java.lang.String label, java.awt.Image upImage, java.awt.Image downImage, int behaviour)
          Creates and initializes a FlexiButton object, with the specified behaviour, label, unpressed-image, and pressed-image.
FlexiButton(java.lang.String label, java.awt.Image upImage, java.awt.Image downImage, java.awt.Image upDisabledImage, java.awt.Image downDisabledImage, int behaviour)
          Creates and initializes a FlexiButton object, with the specified behaviour, label, unpressed-image, pressed-image, unpressed-disabled-image, and pressed-disabled-image.
 
Method Summary
void addNotify()
          Function called when the peer has been created.
java.awt.Image getCurrentImage()
          Returns the current image being shown on the button.
java.awt.Image getDownDisabledImage()
          Gets the current up/unpressed image for the button.
java.awt.Image getDownImage()
          Gets the current down/pressed image for the button.
boolean getDraw3DLabel()
          Determines whether the a 3D label is being shown or not.
int getHMargin()
          Gets the horizontal margin.
int getImagePosition()
          Gets the current compass position of the image.
java.awt.Image[] getImages()
          Returns an array of all images used in the FlexiButton.
java.lang.String getLabel()
          Gets the label for the FlexiButton.
java.awt.Dimension getLargestImageSize()
          Returns the maximum width and height out of all of the images.
boolean getShowImage()
          Determines whether the image is being shown or not.
boolean getShowLabel()
          Determines whether the label is being shown or not.
int getSpacing()
          Gets the value of the spacing variable, which determines the space between the label and the image.
java.awt.Image getUpDisabledImage()
          Gets the current up/unpressed image for the button.
java.awt.Image getUpImage()
          Gets the current up/unpressed image for the button.
int getVMargin()
          Gets the vertical margin.
void measure()
          Calculates the width and height of the FlexiButton based on the size of the label and image.
void paintButton(java.awt.Graphics g, boolean down)
           
java.awt.Dimension preferredSize()
          Gets the preferred size of the FlexiButton.
void setDownDisabledImage(java.awt.Image ddl)
          Sets the down/pressed disabled image for the button.
void setDownImage(java.awt.Image dl)
          Sets the down/pressed image for the button.
void setDraw3DLabel(boolean draw3DLabel)
          Sets whether the label should be shown in 3D or not.
void setHMargin(int hMargin)
          Sets the horizontal margin.
void setImagePosition(int imagePos)
          Sets the current position of the image.
void setLabel(java.lang.String label)
          Sets the label for the FlexiButton.
void setShowImage(boolean showImage)
          Sets whether the image should be shown or not.
void setShowLabel(boolean showLabel)
          Sets whether the label should be shown or not.
void setSpacing(int spacing)
          Sets the amount of space between the label and the image.
void setUpDisabledImage(java.awt.Image udl)
          Sets the up/unpressed disabled image for the button.
void setUpImage(java.awt.Image ul)
          Sets the up/unpressed image for the button.
void setVMargin(int hMargin)
          Sets the vertical margin.
 
Methods inherited from class com.pacist.diamonds.DrawnButton
addActionListener, getBehaviour, getButtonListeners, getNotify, getShadowType, getState, inButton, isArmed, isDown, isSet, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, paintButton, paint, processAction, removeActionListener, setArmed, setBehaviour, set, setEnabled, setNotify, setShadowType, setState, setStates
 
Methods inherited from class com.pacist.diamonds.DiamondCanvas
getTipText, mouseEnter, mouseExit, processMouseEvent, setTipText
 
Methods inherited from class java.awt.Canvas
addNotify, paint
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, print, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

label

protected java.lang.String label
The text label for the button.

upImage

protected java.awt.Image upImage
The image displayed when the button is untouched.

downImage

protected java.awt.Image downImage
The image displayed when the button is being held down.

upDisabledImage

protected java.awt.Image upDisabledImage
The image displayed when the button is untouched, but disabled.

downDisabledImage

protected java.awt.Image downDisabledImage
The image displayed when the button is being held down, but disabled.

width

protected int width
Width of FlexiButton.

height

protected int height
Height of FlexiButton.

hMargin

protected int hMargin
Horizontal margin. Default is 3;

vMargin

protected int vMargin
Vertical margin. Default is 3;

spacing

protected int spacing
Space between the image and the label.

imagePos

protected int imagePos
Position of image relative to the label. Default is WEST of the label.
See Also:
Direction

showImage

protected boolean showImage
Determines whether the image should be shown or not. Default is true.

showLabel

protected boolean showLabel
Determines whether the label should be shown or not. Default is true.

draw3DLabel

protected boolean draw3DLabel
Determines whether a 3D label should be drawn or not. Default is false.

canMeasure

protected boolean canMeasure
Determines whether the button may use the dimensions of the image and label or not. Default is false.
Constructor Detail

FlexiButton

public FlexiButton()
Creates and initializes a FlexiButton object, with the behaviour of a button.

FlexiButton

public FlexiButton(java.awt.Image label)
Creates and initializes a FlexiButton object, with the behaviour of a button, and using the specified image.

FlexiButton

public FlexiButton(java.lang.String label)
Creates and initializes a FlexiButton object, with the behaviour of a button, and using the specified label.

FlexiButton

public FlexiButton(java.lang.String label,
                   java.awt.Image upImage,
                   int behaviour)
Creates and initializes a FlexiButton object, with the specified behaviour, label, and image.

FlexiButton

public FlexiButton(java.lang.String label,
                   java.awt.Image upImage,
                   java.awt.Image downImage,
                   int behaviour)
Creates and initializes a FlexiButton object, with the specified behaviour, label, unpressed-image, and pressed-image.

FlexiButton

public FlexiButton(java.lang.String label,
                   java.awt.Image upImage,
                   java.awt.Image downImage,
                   java.awt.Image upDisabledImage,
                   java.awt.Image downDisabledImage,
                   int behaviour)
Creates and initializes a FlexiButton object, with the specified behaviour, label, unpressed-image, pressed-image, unpressed-disabled-image, and pressed-disabled-image.
Method Detail

preferredSize

public java.awt.Dimension preferredSize()
Gets the preferred size of the FlexiButton.
Returns:
A dimension object indicating this button's preferred size.
Overrides:
preferredSize in class java.awt.Component

getLabel

public java.lang.String getLabel()
Gets the label for the FlexiButton.

setLabel

public void setLabel(java.lang.String label)
Sets the label for the FlexiButton.

getImagePosition

public int getImagePosition()
Gets the current compass position of the image.
See Also:
Direction

setImagePosition

public void setImagePosition(int imagePos)
Sets the current position of the image.
See Also:
getImagePosition()

getUpImage

public java.awt.Image getUpImage()
Gets the current up/unpressed image for the button.
Returns:
Image the current up-image.

setUpImage

public void setUpImage(java.awt.Image ul)
Sets the up/unpressed image for the button.
Parameters:
Image - the new up-image.

getDownImage

public java.awt.Image getDownImage()
Gets the current down/pressed image for the button.
Returns:
Image the current down-image.

setDownImage

public void setDownImage(java.awt.Image dl)
Sets the down/pressed image for the button.
Parameters:
Image - the new down-image.

getUpDisabledImage

public java.awt.Image getUpDisabledImage()
Gets the current up/unpressed image for the button.
Returns:
Image the current up-image.

setUpDisabledImage

public void setUpDisabledImage(java.awt.Image udl)
Sets the up/unpressed disabled image for the button.
Parameters:
Image - the new up-disabled-image.

getDownDisabledImage

public java.awt.Image getDownDisabledImage()
Gets the current up/unpressed image for the button.
Returns:
Image the current up-image.

setDownDisabledImage

public void setDownDisabledImage(java.awt.Image ddl)
Sets the down/pressed disabled image for the button.
Parameters:
Image - the new down-disabled-image.

getSpacing

public int getSpacing()
Gets the value of the spacing variable, which determines the space between the label and the image.

setSpacing

public void setSpacing(int spacing)
Sets the amount of space between the label and the image.
Parameters:
spacing - the amount of space to leave.

getShowImage

public boolean getShowImage()
Determines whether the image is being shown or not.
Returns:
boolean - true if the image is being shown; false otherwise.

setShowImage

public void setShowImage(boolean showImage)
Sets whether the image should be shown or not.
Parameters:
showImage - true if image should be shown; false otherwise.

getShowLabel

public boolean getShowLabel()
Determines whether the label is being shown or not.
Returns:
boolean - true if the label is being shown; false otherwise.

setShowLabel

public void setShowLabel(boolean showLabel)
Sets whether the label should be shown or not.
Parameters:
showLabel - true if label should be shown; false otherwise.

getDraw3DLabel

public boolean getDraw3DLabel()
Determines whether the a 3D label is being shown or not.
Returns:
boolean - true if the label is being shown in 3D; false otherwise.

setDraw3DLabel

public void setDraw3DLabel(boolean draw3DLabel)
Sets whether the label should be shown in 3D or not.
Parameters:
draw3DLabel - true if label should be shown in 3D; false otherwise.

getHMargin

public int getHMargin()
Gets the horizontal margin.

setHMargin

public void setHMargin(int hMargin)
Sets the horizontal margin.

getVMargin

public int getVMargin()
Gets the vertical margin.

setVMargin

public void setVMargin(int hMargin)
Sets the vertical margin.

measure

protected void measure()
Calculates the width and height of the FlexiButton based on the size of the label and image.

getImages

protected java.awt.Image[] getImages()
Returns an array of all images used in the FlexiButton.
Returns:
Image[] - an Image array containing, if present, the upImage, downImage, upDisabledImage, and downDisabledImage.

getLargestImageSize

protected java.awt.Dimension getLargestImageSize()
Returns the maximum width and height out of all of the images. The resulting width and height may not be from the same image.
Returns:
Dimension - maximum width and height out of all of the images.

addNotify

public void addNotify()
Function called when the peer has been created.
Overrides:
addNotify in class java.awt.Canvas

getCurrentImage

protected java.awt.Image getCurrentImage()
Returns the current image being shown on the button. If the button is enabled and is currently, not pressed, then the upImage will be returned. If however the button is pressed down, and the button is disabled, then the downDisabledImage will be returned.
Returns:
Image - the currently viewed image.

paintButton

public void paintButton(java.awt.Graphics g,
                        boolean down)
Overrides:
paintButton in class DrawnButton

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD